home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / gfx / show / svoUtah22.lha / svoUtahRLE / source / URT / lib / vaxshort.c < prev   
C/C++ Source or Header  |  1990-08-02  |  1KB  |  55 lines

  1. /*
  2.  *            V A X S H O R T
  3.  *
  4.  *  Code to manipulate 16-bit integers in VAX order in a
  5.  *  machine independent manner.
  6.  *
  7.  *  (VAX is a trademark of Digital Equipment Corporation)
  8.  *
  9.  *  Author -
  10.  *    Michael John Muuss
  11.  *  
  12.  *  Source -
  13.  *    SECAD/VLD Computing Consortium, Bldg 394
  14.  *    The U. S. Army Ballistic Research Laboratory
  15.  *    Aberdeen Proving Ground, Maryland  21005-5066
  16.  *  
  17.  *  Distribution Status -
  18.  *    Public Domain, Distribution Unlimitied.
  19.  */
  20. #ifndef lint
  21. static char RCSid[] = "@(#)$Id: vaxshort.c,v 3.0 90/08/03 15:21:30 spencer Exp $ (BRL)";
  22. #endif
  23.  
  24. /*
  25.  *            V A X _ G S H O R T
  26.  *
  27.  *  Obtain a 16-bit signed integer from two adjacent characters,
  28.  *  stored in VAX order, regardless of word alignment.
  29.  */
  30. int
  31. vax_gshort(msgp)
  32. char *msgp;
  33. {
  34.     register unsigned char *p = (unsigned char *) msgp;
  35.     register int    i;
  36.  
  37.     if( (i = (p[1] << 8) | p[0]) & 0x8000 )
  38.         return(i | ~0xFFFF);    /* Sign extend */
  39.     return(i);
  40. }
  41.  
  42. /*
  43.  *            V A X _ P S H O R T
  44.  */
  45. char *
  46. vax_pshort(msgp, s)
  47. register char *msgp;
  48. register unsigned short s;
  49. {
  50.  
  51.     msgp[0] = s & 0xFF;
  52.     msgp[1] = s >> 8;
  53.     return(msgp+2);
  54. }
  55.